# Maintainer: David Runge <dvzrv@archlinux.org>

_name=cookiecutter
pkgname=python-cookiecutter
pkgver=2.1.1
pkgrel=3
pkgdesc="A command-line utility that creates projects from project templates"
arch=(any)
url="https://github.com/cookiecutter/cookiecutter"
license=(BSD)
depends=(
  python
  python-binaryornot
  python-click
  python-jinja
  python-jinja-time
  python-pyyaml
  python-requests
  python-slugify
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  git
  python-freezegun
  python-pytest
  python-pytest-mock
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('5e249dab7a71a4213f81b887912d9aae3747b16fce8ede2fb7c7efbd2802871d512540ddc676b9419bafe3b73f0aa5ad6b0b15b16d429f7081e101ad53564193')
b2sums=('17d63625b8822ea3f9b592f5b9ab9ba9b782d3b312ac4aee614e23cba16e4e182b5b2d08197da24c678d25590158a1f8d29c528d2e9437b10bcaabc08ad8dd4d')

prepare() {
  # we do not care about code coverage in pytest runs
  sed -e '/addopts/d' -i $_name-$pkgver/setup.cfg
}

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  export PYTHONPATH="build:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
